<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page import="com.infodms.dms.common.Constant"%>
<%@ page import="java.util.*"%>
<%@taglib uri="/jstl/cout" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<title>经销商仓库维护</title>
<!-- changeFleet(document.getElementById('dealer__').value); -->
</head>
<script type="text/javascript">

function txtClr(valueId) {
	document.getElementById(valueId).value = '' ;
}
</script>

<% String contextPath = request.getContextPath();  %>

<body onload="setShow('<%=Constant.DEALER_WAREHOUSE_TYPE_01 %>');" onunload='javascript:destoryPrototype();' > 

	<div class="navigation"><img src="<%=contextPath%>/img/nav.gif" />&nbsp;当前位置：  整车销售 &gt; 经销商库存管理 &gt; 仓库维护</div>
	<form id="fm" name="fm" method="post">
		<input type="hidden" id="dlrId" name="dlrId" value="" />
		<table class="table_query" border="0">
			<tr>
				<td width="20%" class="tblopt"><div align="right">仓库名称：</div></td>
				<td width="39%" >
      				<input name="warehouseName"  datatype="0,is_textarea,30" type="text" id="warehouseName" class="SearchInput" value="" size="20" />
    			</td>
    			<td width="20%" class="tblopt"><div align="right">仓库类型：</div></td>
				<td width="39%" >
      				<label>
					<script type="text/javascript">
						genSelBoxExp("warehouseType",<%=Constant.DEALER_WAREHOUSE_TYPE%>,"-1",false,"short_sel","onchange='setShow(this.value)'","false",'');
					</script>
				</label>
    			</td>
			</tr>
			<tr>
				<td width="20%" class="tblopt"><div align="right">经销商：</div></td>
				<td width="39%" >
      				<select name="dealer" id="dealer__">
      					<c:forEach var="dealerList_D" items="${dealerList }">
      						<option value="${dealerList_D.DEALER_ID }">${dealerList_D.DEALER_NAME }-${dealerList_D.DEALER_CODE }</option>
\      					</c:forEach>
      				</select>
    			</td>
    			<td width="20%" class="tblopt" id="lowDel__"><div align="right">代管经销商：</div></td>
				<td width="39%" >
				<div id="lowDel__L">
				<input type="hidden"  name="lowID" id="lowID" size="15" value=""/>
				<input type="text"  name="lowDel" id="lowDel" size="15" value="" readonly="readonly" />
				<input name="button2" type="button" class="mini_btn" onclick="showOrgDealer('lowDel', 'lowID', 'false', '', 'true','true');" value="..." />
				<input type="button" class="normal_btn" onclick="txtClr('lowDel');" value="清 空" id="clrBtn" />
				</div>
    			</td>
			</tr>
			<tr>
				<td width="20%" class="tblopt"><div align="right">是否关闭：</div></td>
				<td width="39%" >
      				<label>
					<script type="text/javascript">
						genSelBoxExp("warehouseStatus",<%=Constant.STATUS%>,"-1",false,"short_sel",'',"false",'');
					</script>
				</label>
    			</td>
    			<td width="20%" class="tblopt"><div align="right">备注：</div></td>
				<td width="39%" >
				<textarea id="remark"  name="remark" rows="3" cols="20" datatype="1,is_textarea,2000"></textarea>
    			</td>
			</tr>
			<tr>
			<td colspan="4" align="center"><input type="button" class="cssbutton" name="button3" onClick="addMyStore();" value="保存"/>
			<input type="button" class="cssbutton" name="button4" onClick="toBack();" value="返回"/></td>
			</tr>
		</table>
	</form>
	<script type="text/javascript">

function addMyStore(){
	var a=document.getElementById("dealer__").value;
	var b=document.getElementById("lowID").value;
	if(a==b){
				MyAlert("自身不能作为代交经销商！");
		}else{
	if(submitForm('fm')){
		var lowDelA = document.getElementById('lowDel').value ;
		var warehouseTypeA = document.getElementById('warehouseType').value ;
		if(warehouseTypeA == <%=Constant.DEALER_WAREHOUSE_TYPE_02 %> && lowDelA == '') {
			MyAlert("请选择代管经销商!") ;
		} else {
			fm.action = '<%=contextPath%>/sales/storageManage/MyStore/addMyStore.do';
			fm.submit();
		}
	}
		}
}
function toBack(){
	fm.action = '<%=contextPath%>/sales/storageManage/MyStore/detailMyStore.do';
		fm.submit();
}
function changeFleet(value) {
	var sLowDelName = "" ;
	var sLowDelId = "" ;
	var i = 0;
	
	<c:forEach var="lowDelList_D" items="${lowDelList }">
		if(${lowDelList_D.PARENT_DEALER_D} == value) {
			sLowDelName =sLowDelName+'${lowDelList_D.DEALER_NAME}' + "," ;
			sLowDelId = sLowDelId + '${lowDelList_D.DEALER_ID}' + "," ;
			i++ ;
		}
	</c:forEach>
		document.fm.lowDel__L.options.length=i;
		for(var j=0; j<i; j++) {
			document.fm.lowDel__L.options[j].value=sLowDelId.split(',')[j];
			document.fm.lowDel__L.options[j].text=sLowDelName.split(',')[j];
		}
}
changeFleet(document.getElementById('dealer')) ;
function setShow(value) {
	var iValue = <%=Constant.DEALER_WAREHOUSE_TYPE_01 %>
	if (value == iValue) {
		document.getElementById("lowDel__").style.display = "none";
		document.getElementById("lowDel__L").style.display = "none";
		}
	else {
		document.getElementById("lowDel__").style.display = "inline";
		document.getElementById("lowDel__L").style.display = "inline" ;
		}
} 
</script>
</body>
</html>
		